# by NASA button按下:led逐渐变亮 抬起:led逐渐变暗 
import RPi.GPIO as GP
import time

#11:G17 button
#12:G18 red led
#13:G27 green led

GP.setmode(GP.BOARD)
GP.setup(11,GP.IN,pull_up_down=GP.PUD_DOWN)
GP.setup(13,GP.OUT)
GP.setup(12,GP.OUT)
pwm_red=GP.PWM(12,500)
pwm_green=GP.PWM(13,500)
pwm_green.start(0)
pwm_red.start(0)
#change_dc=
while True:
    if not GP.input(11):
        for dc in range(25):
            pwm_red.ChangeDutyCycle(dc*4)
            print(dc)
            time.sleep(0.5)
    else:
        for dc in range(25,0,-1):
            pwm_red.ChangeDutyCycle(dc*4)
            print(dc)
            time.sleep(0.5)
